/**
 * Created by smp on 2017/5/19.
 */
var modelPath=ROOT_PATH+'/archives/personArchives/securityOrganizationLedger/';
var ORGANIZATION_LEDGER_LEVEL=CONSTANT.DictionaryTypeDefConstants.ORGANIZATION_LEDGER_LEVEL;
var ORGANIZATION_LEDGER_CATEGORY=CONSTANT.DictionaryTypeDefConstants.ORGANIZATION_LEDGER_CATEGORY;
var DEGREE_EDUCATION=CONSTANT.DictionaryTypeDefConstants.DEGREE_EDUCATION;
$('#category').combobox({
    url:ROOT_PATH+'/permission/dictionary/queryDictionaryByDictionaryTypeCode.shtml?code='+ORGANIZATION_LEDGER_CATEGORY,
    required:true,
    editable:false,
    valueField:'id',
    textField:'text'
});
$('#level').combobox({
    url:ROOT_PATH+'/permission/dictionary/queryDictionaryByDictionaryTypeCode.shtml?code='+ORGANIZATION_LEDGER_LEVEL,
    required:true,
    editable:false,
    valueField:'id',
    textField:'text'
});
$('#degreeEducation').combobox({
    url:ROOT_PATH+'/permission/dictionary/queryDictionaryByDictionaryTypeCode.shtml?code='+DEGREE_EDUCATION,
    required:true,
    editable:false,
    valueField:'id',
    textField:'text'
});
$('#unit').combotree({
    url: ROOT_PATH+'/permission/department/getDepartmentTree.shtml?parentId=0'
});
$("#btn_save").click(function(){
    var index=layer.confirm('是否确定保存？', {
        btn: ['确定','取消'] //按钮
    }, function(){
        var isValid = $('#form1').form('validate');
        if (!isValid) {
            layer.close(index);
            layer.msg("请正确填写表单")
        }
        var d = {};
        var t = $('#form1').serializeArray();
        $.each(t, function() {
            d[this.name] = this.value;
        });
        d["categoryName"]=$('#category').combobox("getText");
        d["levelName"]=$('#level').combobox("getText");
        d["degreeEducationName"]=$('#degreeEducation').combobox("getText");
        d["unitName"]=$('#unit').combobox("getText");
        d["sexName"]=$('#sex').combobox("getText");
        $.ajax({
            type:"post",
            url:modelPath+"insertRelation.shtml",
            data:d,
            success:function (data) {
                d["id"]=JSON.parse(data).data;
                WindowManager.closeLayer({
                    returnValue: d
                });
            }
        });
    });

});

